package com.gy.paidao.main.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.amap.api.maps2d.model.BitmapDescriptor;
import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.gy.paidao.R;
import com.gy.paidao.main.bean.ActivityBean;
import com.gy.paidao.util.LogUtil;
import com.gy.paidao.util.map.MapBaseDrawable;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * @author GY
 * @date 2015/7/2
 * @Description:
 */

public class MapDetailMarker extends MapBaseDrawable<ActivityBean> {

    private Context context;
    private View mRoot;
    private LayoutInflater inflater;
    private ImageView imgHead;

    public MapDetailMarker(Context context){
        this.context = context;
        inflater = LayoutInflater.from(context);
        mRoot = inflater.inflate(R.layout.view_marker,null);
        imgHead = (ImageView) mRoot.findViewById(R.id.view_marker_img);
    }

    @Override
    public Bitmap createMarker(ActivityBean bean) {
        mRoot = inflater.inflate(R.layout.view_marker,null);
        imgHead = (ImageView) mRoot.findViewById(R.id.view_marker_img);
        if(!TextUtils.isEmpty(bean.localPath)){
            Bitmap bitmaps = BitmapFactory.decodeFile(bean.localPath);
            imgHead.setImageBitmap(bitmaps);
        }

        BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromView(mRoot);
        LogUtil.e("bitmapDescriptor:"+bitmapDescriptor+"");
        if(bitmapDescriptor != null){
            Bitmap bitmap = bitmapDescriptor.getBitmap();
            return bitmap;
        }
        return null;
    }

}
